﻿
''' <summary>
''' Generic Email schema
''' </summary>
Public Class Email
    Inherits Indexable


    Public Sub New(ByVal content As String, ByVal format As IndexFormats, ByVal received As Date)
        MyBase.New(content, format)
        Me._received = received
    End Sub

    '''<summary> Received time of the email message</summary>
    ''' <remarks>required</remarks>
    Private _received As Date




    ''' <summary>
    ''' Mail header of the e-mail message
    ''' </summary>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _mail_header As String

    ''' <summary>
    ''' Sender of the email message
    ''' </summary>
    ''' <remarks></remarks>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _from As String

    '''<summary>Subject of the email message</summary>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _subject As String

    '''<summary> Recipient(s) of the email message</summary>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _to As String

    '''<summary>Cc field of the email message</summary>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _cc As String
    '''<summary> Bcc field of the email message</summary>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _bcc As String
    '''<summary> ReplyTo field of the email message</summary>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _replyto As String

    '''<summary>Folder name of the email message</summary>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _folder_Name As String
    '''<summary>Bit vector flags</summary>
    ''' <remarks>type="VT_UI4" </remarks>
    <MarshalAs(UnmanagedType.U4)> _
    Private _mail_flags As Integer



    ''' <summary> Bcc field of the email message</summary>
    Public Property Bcc() As String
        Get
            Return _bcc
        End Get
        Set(ByVal value As String)
            _bcc = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary>Cc field of the email message</summary>
    Public Property Cc() As String
        Get
            Return _cc
        End Get
        Set(ByVal value As String)
            _cc = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary>Folder name of the email message</summary>
    Public Property Folder_Name() As String
        Get
            Return _folder_Name
        End Get
        Set(ByVal value As String)
            _folder_Name = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary>
    ''' Sender of the email message
    ''' </summary>
    ''' <remarks></remarks>
    Public Property From() As String
        Get
            Return _from
        End Get
        Set(ByVal value As String)
            _from = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary>Bit vector flags</summary>
    ''' <remarks>type="VT_UI4" </remarks>
    Public Property Mail_flags() As Integer
        Get
            Return _mail_flags
        End Get
        Set(ByVal value As Integer)
            _mail_flags = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary>
    ''' Mail header of the e-mail message
    ''' </summary>
    Public Property Mail_header() As String
        Get
            Return _mail_header
        End Get
        Set(ByVal value As String)
            _mail_header = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary> Received time of the email message</summary>
    ''' <remarks>required</remarks>
    Public ReadOnly Property Received() As Date
        Get
            Return _received
        End Get
    End Property
    ''' <summary> ReplyTo field of the email message</summary>
    Public Property Replyto() As String
        Get
            Return _replyto
        End Get
        Set(ByVal value As String)
            _replyto = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary>Subject of the email message</summary>
    Public Property Subject() As String
        Get
            Return _subject
        End Get
        Set(ByVal value As String)
            _subject = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary> Recipient(s) of the email message</summary>
    Public Property [To]() As String
        Get
            Return _to
        End Get
        Set(ByVal value As String)
            _to = value
            SetOtherPropertiesFlag()
        End Set
    End Property



    Protected Overrides Sub AddRequredProperties(ByVal e As [Event])
        MyBase.AddRequredProperties(e)

        e.AddProperty("received", _received)

    End Sub

    Protected Overrides Sub AddOtherProperties(ByVal e As [Event])
        MyBase.AddOtherProperties(e)

        If Not String.IsNullOrEmpty(_mail_header) Then e.AddProperty("mail_header", _mail_header)

        If Not String.IsNullOrEmpty(_from) Then e.AddProperty("from", _from)
        If Not String.IsNullOrEmpty(_subject) Then e.AddProperty("subject", _subject)
        If Not String.IsNullOrEmpty(_to) Then e.AddProperty("to", _to)
        If Not String.IsNullOrEmpty(_cc) Then e.AddProperty("cc", _cc)
        If Not String.IsNullOrEmpty(_bcc) Then e.AddProperty("bcc", _bcc)
        If Not String.IsNullOrEmpty(_replyto) Then e.AddProperty("replyto", _replyto)
        If Not String.IsNullOrEmpty(_folder_Name) Then e.AddProperty("folder_Name", _folder_Name)




        e.AddProperty("mail_flags", Me._mail_flags)




    End Sub



End Class
